package com.cn.bulu.TEST;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.List;

import javax.sql.DataSource;

import org.junit.Before;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.cn.bulu.dao.HomePageDao;
import com.cn.bulu.pojo.Composition;




public class test {
	 ClassPathXmlApplicationContext ctx;
	 @Before
	    public void init(){
	        ctx=new ClassPathXmlApplicationContext(
	            "spring-mybatis.xml","spring-mvc.xml");	
	      
	    }
	 @Test
	 public void cc() 
		        throws Exception{
		        DataSource ds=ctx.getBean( "dataSource", DataSource.class);
		        System.out.println(ds);
		        Connection conn=ds.getConnection();
		        String sql = "select * from Sample";
		        Statement st=conn.createStatement();
		        ResultSet rs=st.executeQuery(sql);
		        while(rs.next()){
		         System.out.println(rs.getString("type"));
		        } 
		        conn.close();
		    }
	 @Test
	 public void test1(){
		 HomePageDao s = ctx.getBean("homePageDao",HomePageDao.class);
		List<Composition> c = s.selectCompositionBySampleId(1591);
		 System.out.println(c);
		 
	
	 }
	
	 
	 
	 
	 

}
